﻿@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication

@inject NavigationManager Navigation
@inject SignOutSessionStateManager SignOutManager

<AuthorizeView>
    <Authorized>
        <a href="authentication/profile" style="color:aliceblue">你好, @context.User.Identity!.Name!</a>
        <button class="nav-link btn btn-link" style="color:aliceblue" @onclick="BeginSignOut">退出登录</button>
    </Authorized>
    <NotAuthorized>
        @*<a href="authentication/register" style="color:aliceblue">注册</a>*@
        <a href="authentication/login" style="color:aliceblue">登录</a>
    </NotAuthorized>
</AuthorizeView>

@code{
    private async Task BeginSignOut(MouseEventArgs args)
    {
        await SignOutManager.SetSignOutState();
        Navigation.NavigateTo("authentication/logout");
    }
}
